/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-06-02 15:22:10
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-06-06 17:28:42
 * @FilePath: \vue3_upload_file\service\app.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
//引入koa
const Koa = require('koa');
const cors = require('koa2-cors');
const bodyparser = require('koa-bodyparser');
const static = require('koa-static');

const { upload, muti,  cut } = require('./router');
const { start } = require('./utils/chunkClearShedult');

start();

//创建koa对象
const app = new Koa();

// 解决跨域问题
app.use(cors());

// 使用koa-body中间件来解析请求体
app.use(bodyparser({
  enableTypes: ['json', 'form', 'text']
}));

app.use(static(__dirname + '/public'));

app.use(upload.routes()).use(upload.allowedMethods());
app.use(muti.routes()).use(muti.allowedMethods());
app.use(cut.routes()).use(cut.allowedMethods());

//设置监听端口
app.listen(3000, () => {
  console.log('server is running on port 3000');
});